from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.response import Response
from mdapp.models import *
# Create your views here.

class ShowPro(APIView):
    pass

#登录
class Register(APIView):
    def get(self,request):
        name = request.GET.get('name')
        print(name)
        password = request.GET.get('password')
        #查询数据
        user = Users.objects.filter(name=name,password=password).first()
        if user:
            return Response({'code':200,'message':'登录成功','name':user.name})
        else:
            return Response({'code':403,'message':'您的用户名或者密码输入错误'})



class Login(APIView):
    def get(self, request):

        return Response({'code': 200})